<!DOCTYPE html>
<html>
<head>
<meta charset = "UTF-8">
<title>展示学生列表</title>
</head>
<style type = "text/css">
    .list .crumb{
    	 margin:20px;
    	font-size:16px;
    	color:#666;
    }
    .list table{
    	width:85%;
    	margin:0 auto;
    	text-align:center;
    	
    }
    .list table th{
    	border:1px solid #FDD1AE;
    	height:50px;
    	font-size:24px;
    	color:#5D89CE;
    	background-color:#FDEADA;
    }
    .list table td{
    	border:1px solid #FDD1AE;
    	height:40px;
    	font-size:16px;
    	color:#444;
    	background-color:#FDEADA;
    }
    .list table td a{
        font-size:13px;
    	color:#5DB9CE;
    	font-family:'Microsoft YaHei';
    	text-decoration:none;	
    }
    .list table td a:hover{
    	color:#FA3818;
    	text-decoration:underline;
    }
    .page{
    	text-align:center;
    	padding-top:10px;
    	
    }
    .page a{
    	text-decoration:none;
    	color:#5DB9CE;
    	
    }
    .page a:hover{
    	color:#FA3818;
    }
</style>
<body >
<?php 
/*
 * 步骤1：搭建页面
 * 步骤2：自定义函数
 * 步骤3：设置相应参数
 * 步骤4：加载$html    require_once()
 * 步骤5：foreach -> for   定义下标
 * */
require_once "page.php";
//定义数组保存学生信息
$info = array(
    array('name'=>'老五','birth'=>'2001-12-14','subject'=>'PHP','snum'=>'201924433001'),
    array('name'=>'张三','birth'=>'2000-1-14','subject'=>'PHP','snum'=>'201924433002'),
    array('name'=>'李四','birth'=>'2001-2-14','subject'=>'PHP','snum'=>'201924433003'),
    array('name'=>'孙强','birth'=>'2001-3-2','subject'=>'PHP','snum'=>'201924433004'),
    array('name'=>'钱一','birth'=>'2002-12-4','subject'=>'PHP','snum'=>'201924433005'),
    array('name'=>'高星','birth'=>'2003-12-14','subject'=>'PHP','snum'=>'201924433006'),
    array('name'=>'老六','birth'=>'2005-6-14','subject'=>'PHP','snum'=>'201924433007'),
    array('name'=>'冠宇','birth'=>'2001-2-14','subject'=>'PHP','snum'=>'201924433008'),
    array('name'=>'史二','birth'=>'2001-12-14','subject'=>'PHP','snum'=>'201924433009'),
    array('name'=>'陆八','birth'=>'2000-4-14','subject'=>'PHP','snum'=>'201924433010'),
    array('name'=>'老五','birth'=>'1999-12-16','subject'=>'PHP','snum'=>'201924433011'),
    array('name'=>'韩湘','birth'=>'2000-12-14','subject'=>'PHP','snum'=>'201924433012'),
    array('name'=>'潭斯','birth'=>'2000-3-14','subject'=>'PHP','snum'=>'201924433013'),
    array('name'=>'蔡伦','birth'=>'2001-5-6','subject'=>'PHP','snum'=>'201924433014'),
    array('name'=>'白九','birth'=>'2000-12-10','subject'=>'PHP','snum'=>'201924433015'),
    array('name'=>'郑露','birth'=>'2000-12-5','subject'=>'PHP','snum'=>'201924433016'),
    array('name'=>'赵二','birth'=>'2001-4-25','subject'=>'PHP','snum'=>'201924433017'),
    array('name'=>'老三','birth'=>'2003-6-30','subject'=>'PHP','snum'=>'201924433018'),
    array('name'=>'老七','birth'=>'2000-5-24','subject'=>'PHP','snum'=>'201924433019'),
    array('name'=>'老八','birth'=>'2001-8-4','subject'=>'PHP','snum'=>'201924433020'),    
);
$per_page = 5;  //每页显示的条数
$total_num = count($info);//总条数
$total_page = ceil($total_num / $per_page);

$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;//获取当前页码
//页码合理性判断的第二种方式，任选其一即可
$page = max($page,1); //小于1，就等于1，大于1，取自身的值
$page = min($page,$total_page);

$end_index = $per_page*$page - 1;
$end_index = min($end_index,$total_num - 1);

$start_index = $per_page*($page - 1);

?>
	<div class="list">
	<div class="crumb">
		&gt;&gt;&nbsp;学生管理&nbsp;&gt;&gt;&nbsp;0128PHP就业班&nbsp;&gt;&gt;&nbsp;学生列表
	</div>
	<table>
		<tr>
			<th>学号</th>
			<th>姓名</th>
			<th>出生日期</th>
			<th>学科</th>
		</tr>
		<?php 
		  for ($i=$start_index;$i<=$end_index;$i++){
		?>
		<tr>
			<td><?=$info[$i]["snum"]?></td>
			<td><?=$info[$i]["name"]?></td>
			<td><?=$info[$i]["birth"]?></td>
			<td><?=$info[$i]["subject"]?></td>
		</tr>
		<?php 
		  }
		?>
	</table>
	<div class="page">
		<?=showPage($page, $total_page)?>
	</div>
	</div>
</body>
</html>
